package com.dd.cloud.user.service.doctor.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dd.cloud.user.entity.doctor.DoctorTaskRecord;
import com.dd.cloud.user.mapper.doctor.DoctorTaskRecordMapper;
import com.dd.cloud.user.service.doctor.IDoctorTaskRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 医生任务记录表 服务实现类
 * </p>
 *
 * @author czg
 * @since 2024-01-30
 */
@Service
@Slf4j
public class DoctorTaskRecordServiceImpl extends ServiceImpl<DoctorTaskRecordMapper, DoctorTaskRecord> implements IDoctorTaskRecordService {

    @Override
    public void updateTaskStatus(Integer taskId) {
        LambdaQueryWrapper<DoctorTaskRecord> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(DoctorTaskRecord::getStatus, 1)
                .eq(DoctorTaskRecord::getId, taskId);
        DoctorTaskRecord record = this.getOne(queryWrapper);
        if (record == null) {
            return;
        }
        record.setIsShow(0);
        Boolean flag = this.updateById(record);
        if (!flag) {
            log.info("更新任务状态失败");
        }
    }
}
